import axios from "axios";
const HOST = "https://devapi.qweather.com/v7/weather/";
const KEY = "35255e280c604a0cbc6f6a142258d284";
enum DayType {
  Now = "now",
  Seven = "7d",
  Three = "3d",
}
interface ResultDatas {
    fxDate: string;
    sunrise: string;
    sunset: string;
    moonrise: string;
    moonset: string;
    moonPhase: string;
    moonPhaseIcon: string;
    tempMax: string;
    tempMin: string;
    iconDay: string;
    textDay: string;
    iconNight: string;
    textNight: string;
    wind360Day: string;
    windDirDay: string;
    windScaleDay: string;
    windSpeedDay: string;
    wind360Night: string;
    windDirNight: string;
    windScaleNight: string;
    windSpeedNight: string;
    humidity: string;
    precip: string;
    pressure: string;
    vis: string;
    cloud: string;
    uvIndex: string;
  }
async function get7DayDatas(location: string, day: DayType, key = KEY) {
  const params = Object.entries({ location, key })
    .map(([k, v]) => `${k}=${v}`)
    .join("&");
  let url = `${HOST}${day}?`.concat(params);
  return await axios.get(url);
}

export { get7DayDatas, DayType,type ResultDatas };    

